package com.itmiaojie.mapper;

import com.itmiaojie.pojo.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itmiaojie.pojo.vo.ViewCount;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Entity com.itmiaojie.pojo.Article
 */
@Repository
public interface ArticleMapper extends BaseMapper<Article> {

    List<ViewCount> selectViewCount();
    @Select("SELECT id FROM sg_article")
    List<Long> selectIds();
    @Update("UPDATE sg_article  SET view_count = #{count} WHERE id = #{id}")
    void updateViewCount(@Param("id") Long id, @Param("count") Long count);

    void insertTagsAndArticle(@Param("articleId") Long id, @Param("tags") List<Long> tags);
    @Select("SELECT tag_id FROM sg_article_tag WHERE article_id = #{id}")
     List<Long>selectTagIdByArticleId(java.lang.Long id);

    void deleteArticleTagByIds(@Param("id") Long id);
}




